﻿//https://leetcode.cn/problems/animal-shelter-lcci/submissions/602900801/?envType=problem-list-v2&envId=queue

class AnimalShelf {
private:
    queue<int> dog, cat;
public:
    AnimalShelf() {

    }

    void enqueue(vector<int> animal) {
        if (animal[1])
            dog.push(animal[0]);
        else
            cat.push(animal[0]);
    }

    vector<int> dequeueAny() {
        if (cat.empty()) return dequeueDog();
        if (dog.empty()) return dequeueCat();
        //取出来的是编号
        if (cat.front() < dog.front()) return dequeueCat();
        else return dequeueDog();

    }

    vector<int> dequeueDog() {
        if (dog.empty())
            return { -1,-1 };
        int id = dog.front();
        dog.pop();
        return { id,1 };
    }

    vector<int> dequeueCat() {
        if (cat.empty())
            return { -1,-1 };
        int id = cat.front();
        cat.pop();
        return { id,0 };
    }
};

/**
 * Your AnimalShelf object will be instantiated and called as such:
 * AnimalShelf* obj = new AnimalShelf();
 * obj->enqueue(animal);
 * vector<int> param_2 = obj->dequeueAny();
 * vector<int> param_3 = obj->dequeueDog();
 * vector<int> param_4 = obj->dequeueCat();
 */